<div class="page-header">
	<ul id="table-tab" class="nav nav-tabs" role="tablist">
		<li role="presentation" class="active"><a href="#portal-tab"
			aria-controls="portal-tab" role="tab" data-toggle="tab">门户管理</a>
		</li>
	</ul>
</div>
<div class="tab-content">
	<div id="portal-tab" class="tab-pane active" role="tabpanel">
		<div class="row">
            <!--搜索域-->
            <div class="col-xs-12">
            	<div class="search-area">
            		<form id="table-portal-search" class="form-inline">
                        <div class="form-group">
                            <label for="portal.name">名称：</label>
                            <input type="text" class="form-control input-sm" id="portal-name" name="portal.name" value="" placeholder="按名称搜索">
                        </div>
	                    <button id="btn-portal-search" type="button" class="btn btn-info btn-sm no-border">
	                    	<i class="ace-icon fa fa-search bigger-110"></i>查询
	                    </button>
	                    <div class="form-group pull-right">
                    		<span>查询方式：</span>
                           	<label class="radio-inline">
                           		<input type="radio" name="searchType" value="1" checked="checked"/>精确
                           	</label>
                           	<label class="radio-inline">
                           		<input type="radio" name="searchType" value="0"/>模糊
                           	</label>
                        </div>
                    </form>
                </div>
            </div>
        </div>
		<!-- 数据表格 -->
        <div class="row">
            <div class="col-xs-12">
            	<div id="table-portal-toolbar">
            		<div class="btn-group btn-group-sm">
	                    <button id="viewportal" class="btn btn-purple btn-sm no-border" >
	                        <i class="ace-icon fa  fa-eye bigger-110 "></i>查看
	                    </button>
	                    <button id="addportal" class="btn btn-info btn-sm no-border" 
	                    onclick="goAdd('新增门户', 'mnui/ai/portal/add', 'table-portal');">
	                        <i class="ace-icon fa fa-plus bigger-110"></i>新增
	                    </button>
	                    <button id="editportal" class="btn btn-success btn-sm no-border"
	                    onclick="goUpdate('编辑门户', 'mnui/ai/portal/edit', 'table-portal');">
	                        <i class="ace-icon fa fa-pencil-square-o bigger-110"></i>编辑
	                    </button>
	                    <button id="delportal" class="btn btn-danger btn-sm no-border"
	                    onclick="doDels('mnui/ai/portal/deletes', 'table-portal');">
	                        <i class="ace-icon fa fa-trash-o bigger-110"></i>删除
	                    </button>
                    </div>
                </div>
            	<table id="table-portal" 
            			data-toolbar="#table-portal-toolbar" 
            			data-sort-name="uuid" 
            			data-sort-order="asc"
            			data-show-columns="true"
            			data-id-field="uuid">
            		 <thead>
                        <tr>
                            <th data-field="state" data-checkbox="true"></th>
                            <th data-width="120" data-field="name" data-align="left" data-sortable="false">名称</th>
                            <th data-width="180" data-field="linkurl" data-align="left" data-sortable="true">访问地址</th>
                            <th data-width="180" data-field="linkfile" data-align="left" data-sortable="true">模板文件</th>
                            <th data-width="100" data-field="isdefault" data-align="left" data-sortable="true" data-formatter="formatDefault">默认</th>
                            <th data-field="remark" data-align="left" data-sortable="false">描述</th>
                        </tr>
                    </thead>
                </table>
            </div>
        </div>
	</div>
</div>

<script type="text/javascript">

function formatDefault(value, row, index) {
	var val = parseInt(value)
	switch (value) {
	case 0:
		return "<a href=\"javascript:setDefault('"
				+ row.uuid
				+ "')\"><i class=\"ace-icon fa fa-square-o\"></i></a>";
	case 1:
		return "<i class=\"ace-icon fa fa-check-square-o\"></i>";
	default:
		return value;
	}
}

function setDefault(uuid){
	$.ajax({
		url : 'mnui/ai/portal/setDefault',
		type : 'post',
		data : {
			uuid : uuid
		},
		success : function(resp) {
			if (resp.status == "OK") {
				$("#table-portal").bootstrapTable('refresh');
				TipMsg.success(resp.message, 0);
			} else {
				TipMsg.error(resp.message, 0);
			}
		},
		error : function(resp) {
			TipMsg.error("发生错误!", 0);
		}
	});
}

$(document).ready(function(){
	initTableList('table-portal','mnui/ai/portal/dataGrid', 'table-portal-search', 'btn-portal-search');
});
</script>
